package org.corolla.cloth.web.action;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Results;
import org.apache.struts2.convention.annotation.Result;

import com.opensymphony.xwork2.ActionSupport;

@ParentPackage(value = "struts-default")
@Results({
          @Result(name = "input", type = "redirect", location = "/view/login.jsp"),
          @Result(name = "success", type = "redirect", location = "/view/StyleMan.jsp", params = { "message",
                                                                                                  "login success",
                                                                                                  "username",
                                                                                                  "${username}" }) })
@Namespace("/view")
@Action(value = "loginAction")
public class LoginAction extends ActionSupport {

    /**
	 * 
	 */
    private static final long serialVersionUID = 1L;

    private String            username;
    private String            password;

    @Override
    public String execute() throws Exception {
        // 程序运行到execute()时，前面的验证都已经正确了
        // HttpServletRequest request = ServletActionContext.getRequest();
        // HttpSession session = request.getSession();

        if (this.username.equals("corolla") && this.password.equals("corolla")) {
            return SUCCESS;
        }
        return "input";
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

}
